<style>
 .reds { background-color:#FF0000};
 </style>         
<div class="spage-main-box">
<div class="tableform"> 

<h3><div class="message"><strong>买家说：</strong><{$pro_detail.title}></div></h3>

 <div class="division">
<table width="100%" border="0" >
  <tr>
    <th>平台订单号：</th><td><{$order.order_bn}></td>
    </tr><tr>
    <th>订单状态：</th><td><{if $pro_detail.recieved=='true'}>已收货<{else}>未收货<{/if}>,<{if $pro_detail.verify=='true'}>已质检<{else}>未质检<{/if}></td>
 </tr><tr>   
    <th>提出申请的时间：</th><td><{$pro_detail.add_time|cdate:FDATE_STIME}>
    
    </td>
  </tr>
</table>
</div>

<h3>申请售后服务的商品</h3>
<div class="division">
<div class="gridlist">
<table width="100%" border="0">
<thead>
  <tr>
    <th>货号</th>
    <th>商品名称</th>
    <th>数量</th>
    <th>是否校验</th>
    <th>所属仓库</th>
  </tr>
  </thead>
  <tbody>
  <{foreach from=$pro_detail.items item=items}>    
  <tr id="ck<{$items.item_id}>">
    <td><{if $items.is_check=='true'}><{$items.bn}><{else}><{$items.bn}><{/if}></td>
    <td><{$items.name}></td>
    <td><{$items.num}></td>
    <td><{$items.is_check}></td>
    <td><{$items.branch_name}></td>
  </tr>
 <{/foreach}>
 </tbody>
</table>
</div>
</div>

<div class="division">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th><{input type="hidden" name="por_id" value=$pro_detail.por_id}>
    请扫描货号：
    </th>
    <td>
    <input type="text" id="bn" name="bn">
	 <span style="color:red" id="message"></span>
    </td>
  </tr>
</table>
</div>
    
    
    
<{if $pro_detail.attachment!=''}>
<h3>附件下载</h3>
<div class="division">
<table width="100%" border="0">
  <tr>
    <td>
    <{if $attachment_type!='remote'}>
    <a class="margin10" href="javascript:file_download()">请点击下载该附件</a>
    <{else}>
    <a class="margin10" href="<{$pro_detail.attachment}>" target="_blank">请点击下载该附件</a>
    <{/if}>
    </td>
  </tr>
</table>
</div>
<{/if}>


<h3>详细说明</h3>
<div class="division">
<table width="100%" border="0">
  <tr>
    <td> <{$pro_detail.content|escape:"html"}></td>
  </tr>
</table>
</div>
<h3>操作日志</h3>
<div class="division">
<table width="100%" border="0" class="gridlist" cellspacing="0" cellpadding="0" >
<thead>
  <tr>
    <th >操作时间</th>
    <th >操作员</th>
    <th >操作内容</th>
  </tr>
  </thead>
  <tbody>
 <{foreach from=$pro_detail.log item=log}>
  <tr>
    <td><{$log.operate_time|cdate:FDATE_STIME}></td>
    <td><{$log.op_name}></td>
    <td><{$log.memo}></td>
  </tr>
 <{/foreach}>
 </tbody>
</table>
</div>
<form method="post" action="index.php?app=ome&ctl=admin_sv_process&act=edit" id="form-process">

<input type="hidden" id="process_id" name="process_id" value="">
<{input type=hidden name=por_id value=$pro_detail.por_id}>
<{input type=hidden name=return_id value=$pro_detail.return_id}>

<div class="division">
<table width="100%" border="0" class="gridlist">

  <tr>
    <th>售后服务类型：</th>
    <td style="border-bottom:none; padding:0">
    
    <ul style="margin:0; padding:0">
    <{foreach from=$pro_detail.problem_type item=item}>
    <{if !$item.childNode}>
    <li style="float:left; font-weight:bold; color:#3C5283;">
    <input type="checkbox" name="problem_type[]" value="<{$item.problem_id}>"><{$item.cat_name}>
    </li>
	<{else}>
	    <li style="text-align:left; padding:0; float:left; margin-left: 20px; ">
	    <div style="border-bottom:1px solid #E8E8E8; color:#3C5283; padding-left:6px; clear:both; font-weight:bold"><{$item.cat_name}></div>
	    <ol style="margin:0">
	    <{foreach from=$item.childNode item=subitem}>
	        <{if !$subitem.childNode}>
		    <li style="border-bottom:1px solid #E8E8E8; padding-left:10px">
		    <input type="checkbox" name="problem_type[]" value="<{$subitem.problem_id}>"><{$subitem.cat_name}>
		    </li>
		    <{else}>
		        <li style="border-bottom:1px solid #E8E8E8; padding-left:10px">
		        <{$subitem.cat_name}>--
		  
			    <{foreach from=$subitem.childNode item=subitem2}>
	                <{if !$subitem2.childNode}>
		            <li style="border-bottom:1px solid #E8E8E8; padding-left:10px">
		            <input type="checkbox" name="problem_type[]" value="<{$subitem2.problem_id}>"><{$subitem2.cat_name}>
		            </li>
		            <{else}>
		                <li style="border-bottom:1px solid #E8E8E8; padding-left:10px">
		                <{$subitem2.cat_name}>--
		          
		                <{foreach from=$subitem2.childNode item=subitem3}>
		                    <{if !$subitem3.childNode}>
		                    <li style="border-bottom:1px solid #E8E8E8; padding-left:10px">
		                    <input type="checkbox" name="problem_type[]" value="<{$subitem3.problem_id}>"><{$subitem3.cat_name}>
		                    </li>
		                    <{else}>
		                        <li style="border-bottom:1px solid #E8E8E8; padding-left:10px">
		                        <{$subitem3.cat_name}>--
		                  
		                        <{foreach from=$subitem3.childNode item=subitem4}>
		                             <input type="checkbox" name="problem_type[]" value="<{$subitem4.problem_id}>"><{$subitem4.cat_name}>
		                        <{/foreach}>
		                         </li>
		                     <{/if}>
		                <{/foreach}>
		                 </li>
		             <{/if}>
	            <{/foreach}>
                 </li>
		    <{/if}>
	    <{/foreach}>
        </ol>
    <{/if}>
    <{/foreach}>
    </ul>
    </td>
  </tr> 


  <tr style="display:none">
    <th>是否是质量问题：</th>
    <td>
      <input name="is_problem" type="radio" onclick="setView(0)" value="true" checked="checked"/>
      是
      <input type="radio" name="is_problem" value="false" onclick="setView(1)"/>
    否</td>
  </tr>
  <tr id="reason" style="display:none">
    <th>质量问题类型：</th>
    <td>
    
	<{foreach from=$pro_detail.problem_type item=problem_type}>
	<input type="checkbox" name="problem_type[]" value="<{$problem_type.problem_id}>"><{$problem_type.name}>
	<{/foreach}>
	
	</td>
  </tr>
 <tr id="unreason" style="display:none">
    <th>质量问题类型：</th>
    <td>
	<{foreach from=$pro_detail.UnProblemType item=UnProblemType}>
	<input type="checkbox" name="unproblem_type[]"  value="<{$UnProblemType.problem_id}>"><{$UnProblemType.name}>
	<{/foreach}>
	</td>
  </tr> 
  <tr id="belong" style="display:none">
    <th>问题归属：</th>
    <td>
	<{foreach from=$pro_detail.ProblemBelong item=ProblemBelong}>
	<input type="checkbox" name="problem_belong[]" value="<{$ProblemBelong.problem_id}>"><{$ProblemBelong.name}>
	<{/foreach}>
	</td>
  </tr>
 <tr id="unbelong" style="display:none">
    <th>问题归属：</th>
    <td>
	<{foreach from=$pro_detail.UnProblemBelong item=UnProblemBelong}>
	<input type="checkbox" name="unproblem_belong[]" value="<{$UnProblemBelong.problem_id}>"><{$UnProblemBelong.name}>
	<{/foreach}>
	</td>
  </tr> 
  <tr>
    <th>商品入库类型：</th>
    <td style="text-align:left;">
	<{foreach from=$pro_detail.StockType item=StockType key=key}>
		<{if $key == 0}>
		  <input type="radio" name="store_type" value="<{$key}>" <{if $isExistOnlineBranch}>onclick="showOnlineBranch(this)"<{else}>disabled="disabled"<{/if}> vtype="requiredradio"><{$StockType}>
		<{else}>
		  <input type="radio" name="store_type" value="<{$key}>"  <{if $isExistOfflineBranch}>onclick="showOfflineBranch(this)"<{else}>disabled="disabled"<{/if}> vtype="requiredradio"><{$StockType}>
		<{/if}>
	<{/foreach}>
	<div id="instock_branch_el"></div>
	</td>
  </tr>
  <tr>
    <th>质检描述：</th>
    <td style="text-align:left"><textarea name="memo" style="width:400px;"></textarea></td>
  </tr>
</table>
</div>



<div class="table-action">
<{button label="确认" class="btn-primary" id="btn-process" type="submit"}>
</div>
</form>

</div>
</div>
<script>

function file_download(){
  var ifm=new IFrame({src:'index.php?app=ome&ctl=admin_return&act=file_download2&p[0]=<{$pro_detail.return_id}>'});
  ifm.injectAfter(document.body);
}

window.addEvent('domready', function(){
$('bn').focus();

$('form-process').store('target',{
    onRequest:function(){
       $('btn-process').set('disabled', 'true');
    },
    onComplete:function(jsontext){
       var json = Json.evaluate(jsontext);
       if (typeof(json.error) != 'undefined'){
           $('btn-process').set('disabled', '');
       }else{
           $('btn-process').set('disabled', 'true');
           opener.finderGroup['<{$env.get.finder_id}>'].refresh.delay(400,opener.finderGroup['<{$env.get.finder_id}>']);
           window.close();
       }
    }
    });

});

function setView(arg){
	if(arg==0){
		$('reason').style.display = "";
		$('unreason').style.display = "none";
		$('belong').style.display = "";
		$('unbelong').style.display = "none";
	}else if(arg==1){
		$('reason').style.display = "none";
		$('unreason').style.display = "";
		$('belong').style.display = "none";
		$('unbelong').style.display = "";
	}
}

$("bn").addEvent('keydown',function(e){
    if (e.key == 'enter'){
        check();
        return false;
    }
});

function check()
{
	if($('process_id').value!=''){
		var pro = $('process_id').value;
		$('ck'+pro).removeClass('reds');
		$('process_id').value='';
	}
	var bn = $('bn').value;
	$('message').set('html','');
	if(bn==''){
		$('message').set('html','请先扫描货号');
	}else{
		new Request.JSON({url:'index.php?app=ome&ctl=admin_sv_process&act=checks&por_id='+<{$pro_detail.por_id}>+'&bn='+bn, 
    	method:'post',
    	onSuccess:function(data){ 
			if(data.status==1){
				$('message').set('html',data.message);
				$('bn').value='';
			}else{
				$('bn').value='';
				$('ck'+data.item_id).addClass('reds');
				$('process_id').value = data.item_id;
			}
		}
 	}).send(); 
	}
}

function showOfflineBranch(el){
	if(!el.checked)return false;
	new Request.JSON({url:'index.php?app=ome&ctl=admin_sv_process&act=getOfflineBranch', 
	        method:'post',
	        onSuccess:function(data){ 
	          $('instock_branch_el').set('html','');
	           if(data.length == 1){
	               $('instock_branch_el').set('html',data[0].name + '<input type="hidden" name="instock_branch" value="'+data[0].branch_id+'" />');
	           }else{
	               var sel = new Element('select',{'name':'instock_branch'});
	               data.each(function(branch){
	                   var varItem = new Option(branch.name, branch.branch_id);      
	                   sel.options.add(varItem);   
	               });
	               sel.inject($('instock_branch_el'));
	           }
	           
	        }
	    }).send(); 
	
}

function showOnlineBranch(el){
    if(!el.checked)return false;
    new Request.JSON({url:'index.php?app=ome&ctl=admin_sv_process&act=getOnlineBranch', 
        method:'post',
        onSuccess:function(data){ 
          $('instock_branch_el').set('html','');
           if(data.length == 1){
        	   $('instock_branch_el').set('html',data[0].name + '<input type="hidden" name="instock_branch" value="'+data[0].branch_id+'" />');
           }else{
        	   var sel = new Element('select',{'name':'instock_branch'});
        	   data.each(function(branch){
        		   var varItem = new Option(branch.name, branch.branch_id);      
        		   sel.options.add(varItem);   
        	   });
        	   sel.inject($('instock_branch_el'));
           }
           
        }
    }).send(); 
    
}
</script>